<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='zh-CN' xml:lang='zh-CN' xmlns='http://www.w3.org/1999/xhtml'>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta http-equiv="Content-Language" content="zh-CN"/>
        <meta name="robots" content="index, follow" />
        <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico" />
        <title> 我要提问 - 氿上网</title>
        <?php echo $this->_var['system_css']; ?>
        <?php echo $this->_var['base_css']; ?>
        <?php echo $this->_var['system_js']; ?>
        <script type="text/javascript">
            $(function(){
                $("#form_question").validate({
                    rules: {
                        name: {
                            required: true,
                            maxlength:30
                        },
                        content:{
                            required: true,
                            minlength: 20
                        },
                        points:{
                            number:true,
                            max:<?php echo $this->_var['user_account']; ?>
                        }
                    },
                    messages: {
                        name: {
                            required: "标题不能为空!",
                            maxlength: "标题必须小于30位!"
                        },
                        content:{
                            required:'内容不能为空',
                            minlength:'内容必须大于20位'
                        },
                        points:{
                            number:'积分必须为数字',
                            max:"积分最多为<?php echo $this->_var['user_account']['points']; ?>"
                        }
                    }
                });
            })
        </script>
    </head>
    <body>

        <div id="OSC_Screen">
            <?php echo $this->fetch('header.html'); ?>
            <div id="OSC_Content">
                <?php echo $this->fetch('message.html'); ?>
                <div class='QuestionForm'>
                    <form id='form_question' action="<?php echo $this->_var['site_url']; ?>question/ask" method="post">
                        <table border='0'>
                            <tr class='q_title'>
                                <th class='caption'>标 题：</th>
                                <td class='input'>
                                    <input  id='name' class='TEXT' type='text' name='name' size="60" />
                                </td>
                            </tr>
                            <tr class='q_type'>
                                <th class='caption'>分 类：</th>
                                <td class='input'>
                                    <input type='hidden' id='question_type' name='category_id' value='0'/>
                                    <?php $_from = $this->_var['category_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'list');$this->_foreach['l'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['l']['total'] > 0):
    foreach ($_from AS $this->_var['list']):
        $this->_foreach['l']['iteration']++;
?>
                                    <a href='javascript:;' type='<?php echo $this->_var['list']['id']; ?>' title='<?php echo $this->_var['list']['name']; ?>' class='qa_type <?php if (($this->_foreach['l']['iteration'] <= 1)): ?>selected<?php endif; ?>' hidefocus='true'><?php echo $this->_var['list']['name']; ?></a>
                                    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                </td>
                            </tr>

                            <tr class='q_title'>
                                <th class='caption' style="width:70px;">悬赏积分：</th>
                                <td class='input'>
                                    <input  id='points' class='TEXT' type='text' name='points' size="10" />
                                    <p>不填积分为0,当前积分为<font color="red"><?php echo $this->_var['user_account']; ?></font></p>
                                </td>
                            </tr>


                            <tr class='q_title'>
                                <th class='caption'>标签：</th>
                                <td class='input'>
                                    <input  id='tag' class='TEXT' type='text' name='tag' size="60" />
                                    <span id="load_tag"></span>
                                    <p>输入正确的标签,别人更容易找到！多个标签请用空格分开！</p>
                                </td>
                            </tr>
                            <tr>
                                <th class='caption'></th>
                                <td class='input q_content'>
                                    <strong>请对问题进行详细描述：</strong>
                                    <textarea tabindex='7' name="content" id="content" style="width:580px;height:250px;"></textarea>
                                </td>
                            </tr>
                            <tr id='tr_form_msg'><th></th><td colspan='2'></td></tr>
                            <tr class='submit'>
                                <th class='caption'></th>
                                <td class='input'>
                                    <?php if (count ( $this->_var['user'] ) > 0): ?>
                                    <input id="btn_submit" type="submit" value="发表问题 &raquo;" class="SUBMIT" tabindex='8'/>
                                    <?php else: ?>
                                    <input id="btn_submit" type="submit" value="发表问题 &raquo;" class="SUBMIT" tabindex='8' disabled/>
                                    必须登录后才能提问，请点击 <a href="<?php echo $this->_var['site_url']; ?>user/login" target="_blank">这里</a> 登录。
                                    <?php endif; ?>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
                <div class='clear'></div>

            </div>
            <div class='clear'></div>
            <?php echo $this->fetch('footer.html'); ?>
        </div>
        <script>
            $(function(){
                $('.qa_type').click(function(){
                    $('a.qa_type').removeClass('selected');
                    $(this).addClass('selected');
                    $('#question_type').val($(this).attr('type'));
                    return false;
                });
                
                $('#name').focusout(function() {
                    if($('#tag').val() ==''){
                        $.ajax({
                            url:"<?php echo $this->_var['site_url']; ?>ajax/splitword",
                            type:'post',
                            dataType:'text',
                            data:'word='+$(this).val(),
                            beforeSend:function(XMLHttpRequest){
                                $("#load_tag").text("正在加载中...");
                            },
                            success:function(data){
                                $('#tag').val(data);
                                $("#load_tag").text("");
                            }
                        });
                    }
                });
            });
        </script>
    </body>
</html>
